package com.example.demo.stream;

import com.sun.org.apache.xerces.internal.xs.StringList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class DemoStream {
    public static void main(String[] args) {
        //传统写法
        String[] strings=new String []{"s","ss","sssr", "aa", "ssr"};

        //统计出字符长短为2的字符串有多少个
        int num=0;
        for (String string : strings) {
            if(string.length()>2){
                num++;
            }
        }
        System.out.println(num);

        Stream<String> stream = Arrays.stream(strings);
        long count = stream.filter((o) ->
            o.length() > 2
        ).count();
        System.out.println("jdk8 Stream >>>>>>"+count);

    }
}
